// JavaScript Document// JavaScript Document
/* 放在页面中
$(document).ready(function(){
 	showPop(".link-tips1",'#pop-tips1');
});
*/
function showPop(e,popDiv){
	$(e).showPop({popDiv:$(popDiv)});
}
(function($){ 
$.fn.showPop = function(options){ 

	var defaults = { 
		popBg:'.nccp-bg',
		popDiv:'.nccp-pop-div', //内容元素的容器
		popClose:['.nccp-popx','.pop-btn-back'],//点击关闭的元素
	}

	var options = $.extend(defaults, options); 
	var clickBtn = options.clickBtn;
	var popDiv = options.popDiv;
	var popClose = options.popClose;	
	var popBg = options.popBg;
  
	var divH = parseInt($(popDiv).height())/2;
	var divW = parseInt($(popDiv).width())/2;
	var screenW = parseInt($(window).width())/2;
	var screenH = parseInt($(window).height())/2;
	var divLeft = screenW - divW;
	var divTop =  screenH - divH;
	
	$(popDiv).css({position : 'fixed',top:divTop+'px',left:divLeft+'px'});
	
	this.each(function(){
		$(this).click(function(){
			show();
		});
		
		function show(){
		  $("body").append('<div class="nccp-bg"></div>');
			$(popBg).show();
			$(popDiv).show();
			$(popBg).click(function(){
				hide();
			});
		}
				
		function hide(){
			$(popBg).remove();
			$(popDiv).hide();
		}
				 
		for(var i in popClose){
			$(popClose[i]).click(function(){
				hide();
			});
		}
		
	});
};
})(jQuery);
